<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">


    <ui:composition template="/WEB-INF/faces/template.xhtml">
        
        <!--Title -->
        <ui:define name="title">Register</ui:define>
        
        <!--Content-->
         <ui:define name="content">
             
            <h1>Register new user</h1> 
            <h:panelGrid id="reg" columns="2"> 
                <h:form>
                    <table>
                        <tr>
                            <td>Name:</td>
                            <td>
                        <h:inputText label="Username: *"
                                     id="uname" value="#{viewUsersBackningBean.name}"
                                     required="true" styleClass="#{not component.valid ? 'ui-input-invalid' : ''}">
                            <f:ajax render="nameMessage" event="blur"/>
                        <f:validator validatorId="myNameValidator" />    
                        </h:inputText>
                        <h:message id="nameMessage" for="uname" />
                        
                        </td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td>
                        <p:password value="#{viewUsersBackningBean.pwd}"/>
                        <h:message for="upassword" />
                        </td>
                        </tr>
                        <tr>
                            <td>Emil:</td>
                            <td>
                        <h:inputText label="Email: *"
                                     id="uemail" value="#{viewUsersBackningBean.email}"
                                     required="true" styleClass="#{not component.valid ? 'ui-input-invalid' : ''}" >
                            <f:ajax render="emailMessage" event="blur"/>
                        <f:validator validatorId="myEmailValidator" />
                        </h:inputText>
                        <h:message id="emailMessage" for="uemail" />
                        </td>
                        </tr>
                    </table>
                    <h:commandButton value="Submit"  
                                     action="#{userBean.saveUser}"/>
                </h:form>
            </h:panelGrid>
        </ui:define>
    </ui:composition>

</html>